﻿$.extend($.fn.combobox.methods, {
    appendItem: function (jq, item) {
        return jq.each(function () {
            var state = $.data(this, 'combobox');
            var opts = state.options;
            var items = $(this).combobox('getData');
            items.push(item);
            $(this).combobox('panel').append(
                '<div id="' + state.itemIdPrefix + '_' + (items.length - 1) + '"  class="combobox-item">' +
                (opts.formatter ? opts.formatter.call(this, item) : item[opts.textField]) +
                '</div>'
            );
        });
    }
});
$.extend($.fn.validatebox.defaults.rules, {
    exists: {
        validator: function (value, param) {
            var cc = $(param[0]);
            var v = cc.combobox('getValue');
            var rows = cc.combobox('getData');

            for (var i = 0; i < rows.length; i++) {
                if (rows.bankName == v) { return true }
            }
            return false;
        },
        message: 'The entered value does not exists.'
    }
});
